// 类实现接口
interface ClockInterface {
  curentTime: Date
}
class Clock implements ClockInterface {
  curentTime: Date
  constructor(h: number, m: number) {

  }
}
// 在接口中描述一个方法
interface ClockInterface1 {
  currentTime: Date
  setTime(d: Date)
}
class Clock1 implements ClockInterface1 {
  currentTime: Date
  setTime(d: Date) {
    this.currentTime = d
  }
  constructor(h: number, m: number) {}
}

// 类继承类
class Animal {
  constructor(theName: string) {
    this.name = theName
  }
  name: string
  move(distance: number = 0) {
    console.log(`${this.name} moved ${distance}m.`)
  }
}
class Snake extends Animal {
  constructor (name: string) {super(name)}
  move(distance: number = 5) {
    console.log("Slithering...")
    super.move(distance)
  }
}
class Horse extends Animal {
  constructor (name: string) {super(name)}
  move(distance: number = 45) {
    console.log('Galloping...')
    super.move(distance)
  }
}
let sam = new Animal("Sammy the Python")
let tom: Animal = new Horse("Tommy the Palomino")
sam.move()
tom.move(34)
// Sammy the Python moved 0m
// Galloping...
// Tommy the Palomino moved 45m

// 存取器
let passcode = "secret passcode"
class Emploee {
  private _fullName: string
  get fullName(): string {
    return this._fullName
  }
  set fullName(newName: string) {
    if (passcode && passcode === 'secret passcode') {
      this._fullName = newName
    } else {
      console.log("Error: ~~~~~")
    }
  }
}
let emploee = new Emploee()
emploee.fullName = 'Bob'
console.log(emploee.fullName) // Bob